import Cesium, { Color, Ellipsoid, ImageryProvider, Rectangle, TextureMagnificationFilter, TextureMinificationFilter, TilingScheme } from '../Ces/Cesium';

interface EmptyImageryProviderOptions {
    color?: Color;
    tileWidth?: number;
    tileHeight?: number;
    ellipsoid?: Ellipsoid;
    url?: string;
    // Other optional properties can be added here
}

class EmptyImageryProvider implements ImageryProvider {
    private _tilingScheme: TilingScheme;
    private _color: Color;
    private _errorEvent: Event;
    private _tileWidth: number;
    private _tileHeight: number;
    private _readyPromise: Promise<boolean>;
    private _minimumLevel: number;
    private _maximumLevel: number;

    // Default imagery provider properties
    defaultAlpha?: number;
    defaultNightAlpha?: number;
    defaultDayAlpha?: number;
    defaultBrightness?: number;
    defaultContrast?: number;
    defaultHue?: number;
    defaultSaturation?: number;
    defaultGamma?: number;
    defaultMinificationFilter?: TextureMinificationFilter;
    defaultMagnificationFilter?: TextureMagnificationFilter;

    constructor(options?: EmptyImageryProviderOptions) {
        options = options?? Cesium.Frozen.EMPTY_OBJECT

        this._tilingScheme = new Cesium.GeographicTilingScheme({
            ellipsoid: options.ellipsoid,
            numberOfLevelZeroTilesX: 1
        });
        this._color = options.color, Cesium.Color.RED
        this._errorEvent = new Cesium.Event();
        this._tileWidth = options.tileWidth?? 256
        this._tileHeight = options.tileHeight?? 256
        this._readyPromise = Promise.resolve(true);
        this._minimumLevel = 0;
        this._maximumLevel = 0;
    }

    // Properties implementation
    get proxy(): undefined {
        return undefined;
    }

    get tileWidth(): number {
        return this._tileWidth;
    }

    get tileHeight(): number {
        return this._tileHeight;
    }

    get maximumLevel(): number {
        return this._maximumLevel;
    }

    get minimumLevel(): number {
        return this._minimumLevel;
    }

    get tilingScheme(): TilingScheme {
        return this._tilingScheme;
    }

    get rectangle(): Rectangle {
        return this._tilingScheme.rectangle;
    }

    get tileDiscardPolicy(): undefined {
        return undefined;
    }

    //@ts-ignore
    get errorEvent(): Event {
        return this._errorEvent;
    }

    get ready(): boolean {
        return true;
    }

    get readyPromise(): Promise<boolean> {
        return this._readyPromise;
    }

    get credit(): undefined {
        return undefined;
    }

    get hasAlphaChannel(): boolean {
        return true;
    }

    // Methods implementation
    getTileCredits(x: number, y: number, level: number): undefined {
        return undefined;
    }

    //@ts-ignore
    requestImage(x: number, y: number, level: number, request?: Request): Promise<HTMLCanvasElement> {
        const canvas = document.createElement('canvas');
        canvas.width = 1;
        canvas.height = 1;
        return Promise.resolve(canvas);
    }

    pickFeatures(
        x: number,
        y: number,
        level: number,
        longitude: number,
        latitude: number
    ): undefined {
        return undefined;
    }
}

export default EmptyImageryProvider;
